<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta http-equiv="Cache-Control" content="No-Cache">
	<meta http-equiv="Pragma" content="No-Cache">

	<title>운세의 신</title>

	<link rel="stylesheet" type="text/css" href="/css/common.css">
	
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
	<script src="/js/common_basic.js"></script>
	<script src="/js/utility/common_util.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){

		});
		
		// 조회수 랜덤 증가
		function modifyHit(yyyy, mm, artist_idx, op) {
			var frm = document.frm_hit;
			frm.yyyy.value       = yyyy;
			frm.mm.value         = mm;
			frm.artist_idx.value = artist_idx;
			frm.op.value         = op;

			frm.action = '/star/ranking/modify_hit';
			frm.submit();
		}
	
		// 스타 검색 팝업
		function openStarSearch() {
			openPopup("/star/starpt/search", 500, 430);
		}

		
	</script>
</head>
<body>
<form name="frm_hit" method="post">
	<input type="hidden" name="yyyy" />
	<input type="hidden" name="mm" />
	<input type="hidden" name="dd" value="00" />
	<input type="hidden" name="artist_idx" />
	<input type="hidden" name="op" />
</form>

<div id="wrap">
	<!-- Header -->
	<? include_once $_SERVER['DOCUMENT_ROOT'].'/include/commons/header.php'; ?>
	<!--// Header -->
	
	<!-- Contents -->
	<div id="content">
		<h2>스타 궁합 랭킹 관리 - 리스트</h2>
		<div>
<?php
	$target_date = isset($_GET['yyyymm']) ? $_GET['yyyymm'] : date('Ym',time());
	$target_date = date(strtotime(substr($target_date, 0,4).'-'.substr($target_date, 4,2).'-01'));

	$prev  = date('Ym',strtotime("-1 month",$target_date));
	$today = date('Ym',$target_date);
	$next  = date('Ym',strtotime("+1 month",$target_date));
?>
			<table class="basicTable" width="100%" cellpadding="2" cellspacing="1" border="0">
				<thead>
					<tr>
						<th><a href="/star/ranking?yyyymm=<?=$prev?>">◀</a> 기준년월 <a href="/star/ranking?yyyymm=<?=$next?>">▶</a></th>
						<th>순위</th>
						<th>스타No</th>
						<th>이름</th>
						<th>직업</th>
						<th>조회수</th>
						<th>랜덤증감</th>
					</tr>
				</thead>
				<tbody>
<?
	$rank = 1;
	foreach ($list as $item) { ?>
					<tr>
						<td align="center"><?=$item['year']?>-<?=$item['month']?></td>
						<td align="center"><?=$rank++?></td>
						<td align="center"><?=$item['artist_idx']?></td>
						<td align="center"><?=$item['artist_name']?></td>
						<td align="center"><?=$item['job']?></td>
						<td align="center"><?=$item['cnt']?></td>
						<td align="center"><button onclick="modifyHit('<?=$item['year']?>','<?=$item['month']?>','<?=$item['artist_idx']?>','add')">＋</button> <button onclick="modifyHit('<?=$item['year']?>','<?=$item['month']?>','<?=$item['artist_idx']?>','sub')">－</button></td>
					</tr>
<?	} ?>
				</tbody>
			</table>
		</div>
		<br/><br/>
		<h2>스타 궁합 랭킹 등록</h2>
		<div>
			<form method="post" id="frm" action="/star/ranking/write_ok">
				<input type="hidden" name="popular_id" value="main_monthly" />
				<fieldset>
					<table class="basicTable" width="100%" cellpadding="2" cellspacing="1" border="0">
						<thead>
							<tr>
								<th>스타검색</th>
								<th>기준년월</th>
								<th>스타No</th>
								<th>이름</th>
							</tr>
						</thead>
						<tr>
							<td align="center"><input type="button" value="검색" onclick="openStarSearch()" /></td>
							<td align="center"><input type="text" name="yyyy" value="<?=substr($today,0,4)?>" /><input type="text" name="mm" value="<?=substr($today,4,2)?>" /><input type="hidden" name="dd" value="00" /></td>
							<td align="center"><input type="text" name="artist_idx" readonly="readonly" class="roTxt" /></td>
							<td align="center"><input type="text" name="artist_name" readonly="readonly" class="roTxt" /></td>
						</tr>
					</table>
					<input type="submit" value="저장" />
				</fieldset>
			</form>	
		</div>
	</div>
	<!--// Contents -->
	
	<!-- Footer -->
	<? include_once $_SERVER['DOCUMENT_ROOT'].'/include/commons/footer.php'; ?>
	<!--// Footer -->
</div>
</body>
</html>